package com.sqx.modules.creation.controller.app;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONArray;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;

public class TestController {
    public static void main(String[] args) {

        Date date = new Date();
        //Date转LocalDateTime
        LocalDateTime localDateTime = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
        localDateTime = localDateTime.plusDays(1);
        String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);

        LocalDateTime now = LocalDateTime.now();
        int nowYear = now.getYear();
        int nowMonth = now.getMonthValue();
        int nowDay = now.getDayOfMonth();
        int nowHour = now.getHour();
        int nowMinute = now.getMinute();
        int nowSecond = now.getSecond();
        System.out.println("当前时间"+now);
        LocalDateTime dateTime = now.plusDays(1);
        //LocalDateTime转为date
        Date date1 = Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());
        System.out.println("当前时间+1天"+dateTime);
        LocalDateTime dateTime1 = now.minusDays(1);
        System.out.println("当前时间-1天"+dateTime1);
        DateTime dateTime2 = DateUtil.beginOfDay(date1);
        System.out.println("当前时间"+dateTime2);


        String[] colors = {};
        // 将数组转换为字符串,去掉[]
        String join = String.join(",", colors);
        System.out.println(join);

        DateTime yesterday = DateUtil.yesterday();
        System.out.println("yesterday"+yesterday);

    }
}
